<template>
  <div class="staffHome.vue">
    <div v-if="!$store.state.isbusNewsDitle">
      <div class="staff_nav_box">
        <div
          v-for="(item,index) in navList"
          :key="index"
          @click='handNav(item.id)'
          :class="[avtiveId==item.id?'staff_nav_tltle_active':'','staff_nav_tltle pointer']"
        >{{item.name}}</div>

      </div>
      <div class="img_box">
        <img
          src="../../../assets/imges/wzhixian.png"
          alt=""
          v-if="navList[3].id!=avtiveId"
        >
      </div>
    </div>
    <div v-if="navList[0].id==avtiveId">
      <staffHomePhotography
        :sonid=navList[0].id
        :ditleList="ditleList"
      ></staffHomePhotography>
    </div>
    <div v-if="navList[1].id==avtiveId">
      <staffHomeActiv
        :sonid=navList[1].id
        :ditActiv="ditActiv"
      ></staffHomeActiv>
    </div>
    <div v-if="navList[2].id==avtiveId">
      <staffHomeCulture
        :sonid=navList[2].id
        :cultureList="cultureList"
      ></staffHomeCulture>
    </div>
    <div v-if="navList[3].id==avtiveId">
      <staffHomePoem
        :sonid=navList[3].id
        :pomeList="pomeList"
      ></staffHomePoem>
    </div>
  </div>
</template>

<script>
import staffHomePhotography from "./staffHomePhotography";
import staffHomeActiv from "./staffHomeActiv";
import staffHomeCulture from "./staffHomeCulture";
import staffHomePoem from "./staffHomePoem";
export default {
  name: "staffHome.vue",
  watch: {
    sonList(newlIst, olist) {
      newlIst.forEach(item => {
        item.forEach(ele => {
          ele.img = ele.img.replace(/\\/g, "/");
          ele.img = this.$store.state.baseUrl + ele.img;
        });
      });
      console.log(newlIst, "职工之家");
      this.ditleList = newlIst[0];
      this.ditActiv = newlIst[1];
      this.cultureList = newlIst[2];
      this.pomeList = newlIst[3];
    }
  },
  props: {
    sonList: {
      type: Array
    }
  },
  components: {
    staffHomePhotography,
    staffHomeActiv,
    staffHomeCulture,
    staffHomePoem
  },
  data() {
    return {
      avtiveId: 29,
      ditActiv: [],
      pomeList: [],
      cultureList: [],
      ditleList: [],
      navList: [
        {
          name: "职工摄影",
          id: 0
        },
        {
          name: "职工活动",
          id: 1
        },
        {
          name: "职工文化",
          id: 2
        },
        {
          name: "职工文苑",
          id: 3
        }
      ]
    };
  },
  mounted() {
    this.$api
      .getZgHome({
        parentId: 28,
        page: 1,
        limit: 10
      })
      .then(res => {
        this.navList.forEach((item, index) => {
          item.id = res.data.data[index].data[0].sortId;
        });
        console.log(this.navList, "职工之家1111");
      });
  },
  methods: {
    handNav(id) {
      this.avtiveId = id;
    }
  }
};
</script>

<style lang='scss' scoped>
.img_box {
  text-align: center;
  margin-bottom: 26px;
}
.staff_nav_box {
  display: flex;
  justify-content: space-between;
  padding-right: 20px;
  padding-left: 20px;
  margin-bottom: 25px;

  .staff_nav_tltle {
    width: 155px;
    height: 38px;
    background: rgba(230, 230, 230, 1);
    text-align: center;
    line-height: 38px;
    color: #333333;
    font-size: 16px;
  }
  .staff_nav_tltle_active {
    background: rgba(218, 0, 0, 1);
    font-size: 16px;
    color: #ffffff;
  }
}
</style>
